let ajax = getApp().globalData.ajax;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    balance:0.00,
    couponIcon:'http://image.tanwancat.com/21e9d1e609d1fb104af1c33c8ea21a47_64_64.jpeg',//优惠券图标
    jfIcon:'http://image.tanwancat.com/2ef60bc5e5ea2e7d36a94531620728e0_64_64.jpeg',//积分图标
    chongzhiIcon:'http://image.tanwancat.com/94bf94c1486f3370c8c89620a52131be_48_48.jpeg',//重置图标
    tixianIcon:'http://image.tanwancat.com/0b8cc46f1b3bc9c17350e54fdc09f907_48_48.jpeg',
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let json = {
      token: wx.getStorageSync('Cookie'),
      skip: this.data.skip,
      take: this.data.take,
    }
    this.getData(json);
  },

  getData(json){
    ajax('user/finance', json,).then(res=>{
      let balance = res.data.balance;
      balance = (balance).toFixed(2);
      this.setData({ balance});
    })
  },
  toDetail(){
    wx.navigateTo({
      url: '../walletDetails/walletDetails',
    })
  },

  toCoupon(){
    wx:wx.navigateTo({
      url: '../myCoupon/myCoupon',
      success: function(res) {},
      fail: function(res) {},
      complete: function(res) {},
    })
  },

  toRecharge(){
    wx.navigateTo({
      url: '../recharge/recharge?balance=' + this.data.balance,
    })
  },

  toWithdraw(){
    wx.navigateTo({
      url: '../withdrawals/withdrawals?balance=' + this.data.balance,
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})